﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.HtmlControls;

namespace JqueryNet.FormControl.FormHtmlControl
{
    //span div
    public class JHtmlGenericControl : JHtmlContainerControl// JHtmlControl
    {
        HtmlGenericControl _Html;

        public JHtmlGenericControl(HtmlGenericControl _html)
            : base(_html)
        {
            _Html = _html;                   
        }

        public override void Attr(string key)
        {
            switch (key.ToLower())
            {
                case "tag":
                case "tagname":
                    GetTagName(); return;                 
                default:
                    base.Attr(key); return;
            }
        }

        public override void Attr(string key, string value)
        {
            bool f;
            bool.TryParse(value, out f);
            switch (key.ToLower())
            {
                case "tag":
                case "tagname":
                    SetTagName(value); return;    
                default:
                    base.Attr(key, value); return;
            }
        }     

        protected void GetTagName()
        {
            Value = _Html.TagName;
        }

        protected void SetTagName(string value)
        {
            _Html.TagName = value;
        }

        public override void Html()
        {
            Value = _Html.InnerHtml;
        }

        public override void Html(Func<string> fun)
        {
            _Html.InnerHtml = fun();
        }

        public override void Html(string value)
        {
            _Html.InnerHtml = value;
        }

        public override void Text()
        {
            Value = _Html.InnerText;
        }

        public override void Text(Func<string> fun)
        {
            _Html.InnerText = fun();
        }

        public override void Text(string value)
        {
            _Html.InnerText = value;
        }

    }
}
